#ifndef IMAGEREADER_H
#define IMAGEREADER_H

#include <vector>

#include <QImage>

namespace qrcode {

class ImageReader
{
private:
    int version;
    int nMods;
    int maskNum;

    QImage image;

    std::vector<int> databitstream;  //数据流
    std::pair<std::vector<int>, std::vector<int>> formatbits;     //格式信息
    std::pair<std::vector<int>, std::vector<int>> versionbits;    //版本信息

    std::vector<int> ReadDataBits();
    std::pair<std::vector<int>, std::vector<int>> ReadFormatBits();
    std::pair<std::vector<int>, std::vector<int>> ReadVersionBits();
    std::vector<std::pair<int, int> > lockModules;

    int PixelValue(int x, int y);
    bool IsLockModule(int x, int y);

public:
    ImageReader();

    void ReadBits();
    void ReadFormatVertionBits();
    void setImage(const QImage &value);
    std::vector<int> getDatabitstream() const;
    std::pair<std::vector<int>, std::vector<int> > getFormatbits() const;
    std::pair<std::vector<int>, std::vector<int> > getVersionbits() const;
    int getVersion() const;
    void setMaskNum(int value);
};

}

#endif // IMAGEREADER_H
